package com.example.ex_intent;

import android.content.Intent;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;

public class ResultActivity extends AppCompatActivity {
    private Intent intent;
    private Bundle bundle;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_result);

        Bundle bundle = this.getIntent().getExtras();
        String ans = bundle.getString("ans");

        String sexText = "";
        if(ans.equals("篮球")){
            sexText = "篮球";
        }else if(ans.equals("足球")){
            sexText = "足球";
        }else if(ans.equals("吉他")){
            sexText = "吉他";
        }else{
            sexText = "跳舞";
        }

        TextView tv = (TextView)findViewById(R.id.text1);
        tv.setText("你的爱好是："+sexText);

        Button bn = (Button)findViewById(R.id.btn3);
        bn.setOnClickListener(new Button.OnClickListener(){
            @Override
            public void onClick(View v){
                ResultActivity.this.setResult(RESULT_OK,intent);
                ResultActivity.this.finish();
            }
        });
    }
}
